/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package sfs2x.extension.fourinarow.main;

import com.athena.objects.Game;
import com.athena.objects.Player;
import com.smartfoxserver.v2.entities.User;
import com.smartfoxserver.v2.entities.data.ISFSObject;
import com.smartfoxserver.v2.extensions.BaseClientRequestHandler;

/**
 *
 * @author dodinhchien
 */
public class StartHandle extends BaseClientRequestHandler {

    @Override
    public void handleClientRequest(User user, ISFSObject params) {
        FourinarowExtension extension = (FourinarowExtension) getParentExtension();
        Player player = extension.getUsersList().get(user.getId());
        if (player.getRoomId() != -1) {
            Game game = extension.getGamesList().get(player.getRoomId());
            if (game != null) {
                if (game.getPlayers().size() == 2) {
                    game.Start(extension);
                } else {
                    trace("game dont exist");
                }
            }
        }

    }

}
